<?php

/**
 * This is the model class for table "service".
 *
 * The followings are the available columns in table 'service':
 * @property string $id
 * @property string $service_type
 * @property string $title
 * @property string $desc
 * @property string $image_1
 * @property string $image_2
 * @property string $video_url
 * @property string $content
 * @property string $price
 * @property string $status
 * @property string $is_deleted
 * @property string $create_date
 * @property string $update_date
 */
class Service extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Service the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'service';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('service_type, title, content, price, create_date', 'required'),
			array('service_type', 'length', 'max'=>11),
			array('title, image_1, image_2, video_url', 'length', 'max'=>50),
			array('desc', 'length', 'max'=>255),
			array('price', 'length', 'max'=>20),
			array('status, is_deleted', 'length', 'max'=>1),
			array('update_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, service_type, title, desc, image_1, image_2, video_url, content, price, status, is_deleted, create_date, update_date', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'service_type' => 'Service Type',
			'title' => 'Title',
			'desc' => 'Desc',
			'image_1' => 'Image 1',
			'image_2' => 'Image 2',
			'video_url' => 'Video Url',
			'content' => 'Content',
			'price' => 'Price',
			'status' => 'Status',
			'is_deleted' => 'Is Deleted',
			'create_date' => 'Create Date',
			'update_date' => 'Update Date',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('service_type',$this->service_type,true);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('desc',$this->desc,true);
		$criteria->compare('image_1',$this->image_1,true);
		$criteria->compare('image_2',$this->image_2,true);
		$criteria->compare('video_url',$this->video_url,true);
		$criteria->compare('content',$this->content,true);
		$criteria->compare('price',$this->price,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('is_deleted',$this->is_deleted,true);
		$criteria->compare('create_date',$this->create_date,true);
		$criteria->compare('update_date',$this->update_date,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}
